/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.sena.jme.curso;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.*;

/**
 * @author jfnanezg@gmail.com
 */
public class ImagenInmutable extends MIDlet implements CommandListener {

    private Display display;
    private Form form;
    private Command exit;

    public void startApp() {
        display = Display.getDisplay(this);

        exit = new Command("Salir", Command.EXIT, 1);
        form = new Form("");
        form.addCommand(exit);
        form.setCommandListener(this);
        try {
            Image image = Image.createImage("/mobile.png");
            Image image1 = Image.createImage("/phone.png");
            form.append(new ImageItem(null, image, ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_AFTER, null));
            form.append(new ImageItem(null, image1, ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_AFTER, null));
            display.setCurrent(form);
        } catch (java.io.IOException e) {
            System.err.println(e);
        }
        display.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        notifyDestroyed();
    }

    public void commandAction(Command c, Displayable s) {
        String label = c.getLabel();
        if (label.equals("Salir")) {
            destroyApp(false);
        }
    }
}
